********************************************************************************
********************************************************************************
* Title:		summarystats
* Project:		Stress, Ethnicity, and Prosocial Behavior
* Author:		Moritz Poll (moritz.poll@brown.edu)
* PIs:			Johannes Haushofer, Sara Lowes, Abednego Musau, David Ndetei, 
*				Nathan Nunn, Moritz Poll, Nancy Qian
* Purpose:		Summary Statistics Tables and Figures
********************************************************************************
********************************************************************************

set more off
set trace off
pause on
noisily dis as input "Start: Summary Statistics"

********************************************************************************
***************************** Average Allocations ******************************
********************************************************************************

use "$cleandata_dir/HIO_for_analysis_xlong.dta", clear
local hist_dg					`"width(0.1) xtitle("Share allocated to matched player in the $dg_name")"'
local hist_cyd	 				`"discrete barwidth(.75) xscale(r(0  2)) xlabel(0 "Person A" 1 "Person B") xtitle("Chosen person in the $cyd_name")"'
local hist_tg1		 			`"discrete xlabel(0 0.2 0.4 0.6 0.8 1) xtitle("Share allocated to matched player in the $tg1_name")"'
local hist_tg2				 	`"width(0.1) xtitle("Share returned to matched player in the $tg2_name")"'
local hist_likely_to_be_friends	`"discrete xlabel(1 "Very unlikely" 2 "Unlikely" 3 "Neither" 4 "Likely" 5 "Very likely") xtitle("How likely are you to be friends" "with a person with the following characteristics?")"'
local hist_trust 				`"discrete xlabel(1 "Not at all" 2 "A bit" 3 "Somewhat" 4 "Mostly" 5 "Completely") xtitle("How much do you trust a person with the following characteristics?")"'
local hist_closeness 			`"discrete xlabel(0(1)5) xtitle("Using the figures provided, which set of figures best represents" "how close you feel to a person with the following characteristics?")"'
local hist_social_proximity		`"width(0.1) xtitle("Rescaled social proximity survey questions")"'
local hist_demand				`"width(0.1) xtitle("Share allocated to matched player" "in the $demand_name")"'

foreach var in cyd likely_to_be_friends closeness trust social_proximity {
	if "`var'" == "cyd" hist decision if game == 3, $hist_design `hist_`var''
	else hist decision if game_str == "`var'", $hist_design `hist_`var''
	graph export "$figures_dir/hist_`var'.pdf", replace
}

foreach var in dg tg1 tg2 demand {
	hist share if game_str == "`var'", $hist_design `hist_`var''
	graph export "$figures_dir/hist_`var'.pdf", replace
}
********************************************************************************
***************************** Session Statistics *******************************
********************************************************************************

use  "$cleandata_dir/HIO_for_analysis_session.dta", clear 

graph bar ts_invites ts_showup ts_participated, over(session, gap(0) label(alternate angle(90))) bar(1, color(orange_red)) bar(2, color(dkorange)) bar(3, color(gold)) bargap(-100) $bar_design xsize(14) legend(order(1 "Invited" 2 "Showed up" 3 "Participated") rows(1) size(medlarge) title(By session, size(medlarge) color(black)) region(color(none))) ytitle("Participants invited, showed up and participated")
graph export "$figures_dir/session_showup.pdf", replace
graph bar luo kikuyu luhya kamba, over(session, gap(0) label(alternate angle(90))) stack $bar_design xsize(14) legend(order(1 "Luo" 2 "Kikuyu" 3 "Luhya" 4 "Kamba") size(medlarge) rows(1) title(By session, size(medlarge) color(black)) region(color(none))) ytitle("Share of participants from each ethnicity")
graph export "$figures_dir/session_composition_eth.pdf", replace
graph bar pool_kibera pool_kawangware pool_viwandani, over(session, gap(0) label(alternate angle(90))) bar(1, color(ebblue)) bar(2, color(midgreen)) bar(3, color(cranberry)) stack $bar_design xsize(14) legend(order(1 "Kibera" 2 "Kawangware" 3 "Viwandani") rows(1) size(medlarge) title(By session, size(medlarge) color(black)) region(color(none))) ytitle("Share of participants from each settlement")
graph export "$figures_dir/session_composition_settlement.pdf", replace

noisily dis as input "End: Summary Statistics"
